﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DesignPattern
{
    public class Context
    {
        private Strategy Stg;
    
        public Context(string opt)
        {
            switch (opt)
            {
                case "无优惠":
                    Stg = new StrategyNormal();
                    break;
                case "八折":
                    Stg = new StrategyDiscount(0.8);
                    break;
                case "满100减10":
                    Stg = new StrategyReturn(100, 10);
                    break;
                default:
                    Stg=new StrategyNormal();
                    break;
            }
        }

        public double GetResult(double cash)
        {
            double result=Stg.AcceptCash(cash);
            return result;
        }
    }
}
